package bsea.jan18;

import java.sql.SQLException;

public class UserManager {
	public boolean select(User user){
		DatebaseManager dm=new DatebaseManager();
		dm.getCon();
		dm.read("select * from user where username='"+user.getUserName()+"'");
		if(dm.getRs()==null){
			System.out.println("不存在该用户");
		}else{
			System.out.println("coming else");
			try {
				while(dm.getRs().next()){
					System.out.println("用户名："+user.getUserName()+'\t'+"当前密码："+dm.getRs().getString("pwd")+'\t'+"用户ID："+dm.getRs().getString("id"));
				}
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		dm.closeRs();
		dm.closePs();
		dm.closeCon();
		return true;
	}
	public boolean update(User user){
		DatebaseManager dm=new DatebaseManager();
		dm.getCon();
		dm.update("update user set pwd='"+user.getPwd()+"' where username='"+user.getUserName()+"'");
		dm.closePs();
		dm.closeCon();
		return true;
	}
}
